package com.fw.web.controller.system;

import java.util.List;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.fw.annotation.Log;
import com.fw.core.controller.BaseController;
import com.fw.core.domain.AjaxResult;
import com.fw.enums.BusinessType;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import javax.validation.Valid;
import static com.fw.mes.ResultUtils.success;
import com.fw.system.admin.domain.TbSignUser;
import com.fw.system.admin.service.ITbSignUserService;
import com.fw.utils.poi.ExcelUtil;
import lombok.RequiredArgsConstructor;
import com.fw.core.page.TableDataInfo;

/**
 * 签到Controller
 * 
 * @author yanwei
 * @date 2023-04-04
 */
@Api(tags = "sign_user")
@RestController
@RequestMapping("/admin/sign_user")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class TbSignUserController extends BaseController
{
    @Autowired
    private ITbSignUserService tbSignUserService;

    /**
     * 查询签到列表
     */
    @PreAuthorize("@ss.hasPermi('admin:sign_user:list')")
    @GetMapping("/list")
    @ApiOperation("查询签到列表")
    public TableDataInfo list(TbSignUser tbSignUser)
    {
        startPage();
        List<TbSignUser> list = tbSignUserService.selectTbSignUserList(tbSignUser);
        return getDataTable(list);
    }

    /**
     * 导出签到列表
     */
    @PreAuthorize("@ss.hasPermi('admin:sign_user:export')")
    @Log(title = "签到", businessType = BusinessType.EXPORT)
    @ApiOperation("导出签到列表")
    @GetMapping("/export")
    public AjaxResult export(TbSignUser tbSignUser)
    {
        List<TbSignUser> list = tbSignUserService.selectTbSignUserList(tbSignUser);
        ExcelUtil<TbSignUser> util = new ExcelUtil<TbSignUser>(TbSignUser.class);
        return util.exportExcel(list, "sign_user");
    }

    /**
     * 获取签到详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:sign_user:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取签到详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(tbSignUserService.selectTbSignUserById(id));
    }

    /**
     * 新增签到
     */
    @PreAuthorize("@ss.hasPermi('admin:sign_user:add')")
    @Log(title = "签到", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增签到")
    public AjaxResult add(@RequestBody TbSignUser tbSignUser)
    {
        return toAjax(tbSignUserService.insertTbSignUser(tbSignUser));
    }

    /**
     * 修改签到
     */
    @PreAuthorize("@ss.hasPermi('admin:sign_user:edit')")
    @Log(title = "签到", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改签到")
    public AjaxResult edit(@RequestBody TbSignUser tbSignUser)
    {
        return toAjax(tbSignUserService.updateTbSignUser(tbSignUser));
    }

    /**
     * 删除签到
     */
    @PreAuthorize("@ss.hasPermi('admin:sign_user:remove')")
    @Log(title = "签到", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除签到")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbSignUserService.deleteTbSignUserByIds(ids));
    }
}
